// Copyright 2011 Google Inc. All Rights Reserved.
// Author: jacobsa@google.com (Aaron Jacobs)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * An action is a set of commands that create a set of output files given a set
 * of input files. It can have arbitrary user info associated with it, for use
 * by code that generates other actions.
 *
 * @param {string} name
 *     The name of the action. This must be of the form
 *
 *         foo/bar:baz
 *
 *     where foo/bar is the containing package (i.e. the project-relative
 *     directory containing a FLAME file).
 *
 * @constructor
 */
flame.Action = function(name) {
  // Make sure that the name is legal.
  flame.internal.parseActionName(name);

  // Set up defaults.
  this.name = name;
  this.inputs = [];
  this.outputs = [];
  this.commands = [];
  this.userInfo = {};
};

/**
 * @type {string} name
 *     The name of this action, in the form 'foo/bar:baz'.
 */
flame.Action.prototype.name;

/**
 * A set of files to regard as the inputs to this action, specified as
 * project-relative paths. The action will be re-run when any file in this set
 * changes (or when the set itself changes). It is not allowed to make use of
 * any project file outside of this set, and flame reserves the right to not
 * make any other files available to it.
 *
 * @type {!Array.<string>}
 */
flame.Action.prototype.inputs;

/**
 *  The set of files that this action promises to write, specified as
 *  project-relative paths. The action must write out these files or it will be
 *  regarded as failing.
 *
 * @type {!Array.<string>}
 */
flame.Action.prototype.outputs;

/**
 * A set of commands comprising the action. These will be run by flame in a
 * directory containing all of the input files listed in the inputs parameter
 * (along with their directories).
 *
 * Each command must return a zero exit code or it will be regarded as failing.
 * flame reserves the right to run these commands in parallel; if they must be
 * done in series then use a shell separator like '&&' to make that happen.
 *
 * @type {!Array.<string>}
 */
flame.Action.prototype.commands;

/**
 * An arbitrary object that can be accessed by other code using
 * flame.getUserInfoForAction.
 *
 * @type {!Object}
 */
flame.Action.prototype.userInfo;
